Skip to content

Add per-GM event scoping to the channel templates (consume assigned_gm)#32

Open
kylecarbonneau wants to merge 1 commit into
taskyou:feat/channels-integrationfrom
kylecarbonneau:pr/channel-gm-scoping
Open

Add per-GM event scoping to the channel templates (consume assigned_gm)#32
kylecarbonneau wants to merge 1 commit into
taskyou:feat/channels-integrationfrom
kylecarbonneau:pr/channel-gm-scoping

Conversation

@kylecarbonneau
Copy link
Copy Markdown

Makes the TaskYou Claude Code channel multi-GM aware, consuming the new assigned_gm field shipped in bborn/taskyou#561 (the ty binary now sets TASK_ASSIGNED_GM on event hooks and accepts --assigned-gm on ty create).

What

When several GMs share a single TaskYou daemon, the channel now:

  1. Stamps the tasks it creates with --assigned-gm <GM_SLUG> — only on ty create, idempotent (skipped when the caller already passed --assigned-gm).
  2. Filters the events it surfaces to the current GM — emits an event when its assigned_gm matches this GM's slug, or when it's unassigned and the GM opts into seeing unassigned events (SEE_UNASSIGNED, default true).

Files (additive — no deletions):

  • templates/channel/taskyou-channel.ts.tmpl — new GM_SLUG (process.env.GM_SLUG || process.env.GM_ALIAS || {{GM_ALIAS}}) and SEE_UNASSIGNED consts; --assigned-gm auto-injection on ty create (idempotent); notification filter in pollNotifications (the line cursor always advances — only the emit is gated, so nothing is lost from the read position); assigned_gm added to the emitted notification meta.
  • templates/hooks/task.completed.tmpl, templates/hooks/task.blocked.tmpl — emit "assigned_gm": "$TASK_ASSIGNED_GM" in the JSON line.
  • config.example.env — documents GM_SLUG (derives from GM_ALIAS) and SEE_UNASSIGNED.

Why

Channel-side companion to #561: it turns the daemon's per-task GM attribution into actual per-session event routing, so one shared daemon fans tasks/notifications out to the correct GM instead of broadcasting every event to every GM.

Additive on top of #28 (the channels integration) and independent of the local-mode/macOS work (#31) — branched directly off #28 so it's cleanly mergeable on its own (verified zero-conflict merge with #31 in either order). Fully backward-compatible: with no config and an older ty (no assigned_gm), SEE_UNASSIGNED defaults to true, so unassigned events still surface and tasks are stamped with the GM's existing alias. The SSH/remote command path is untouched.

How tested

  • Channel template: rendered with sample setup env (GM_ALIAS=acme); GM_SLUG substitutes to the alias default. bun build clean (transpile + full bundle against the MCP SDK).
  • Hook templates: bash -n clean; rendered task.completed with TASK_ASSIGNED_GM set and a quote-containing title emits valid, correctly-escaped JSON with assigned_gm populated.
  • Confirmed the diff has no file deletions and touches only the four named templates.

Consume ty's new assigned_gm field (TASK_ASSIGNED_GM env var, shipped in
bborn/taskyou PR #561) so a single TaskYou daemon shared by multiple GMs
can scope task events per GM.

Channel template (templates/channel/taskyou-channel.ts.tmpl):
- Add GM_SLUG (process.env.GM_SLUG || GM_ALIAS, defaulting to the
  setup-time {{GM_ALIAS}}) and SEE_UNASSIGNED (default true) consts.
- Auto-inject `--assigned-gm <GM_SLUG>` on `ty create` only, idempotent
  (skipped if the caller already passed --assigned-gm).
- Filter emitted notifications: emit when assigned_gm === GM_SLUG, or when
  unassigned (missing/blank) and SEE_UNASSIGNED. Malformed lines are treated
  as unassigned. The line cursor always advances; only the emit is gated.
- Surface assigned_gm in the notification meta.

Hook templates (task.completed, task.blocked):
- Emit assigned_gm (from $TASK_ASSIGNED_GM) in the JSON line.

config.example.env:
- Document GM_SLUG (derives from GM_ALIAS) and SEE_UNASSIGNED.

Additive only; existing behavior — including the SSH/remote path — is
unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant